package com.baizhi.service.impl;

import com.baizhi.entity.BzLog;
import com.baizhi.dao.BzLogMapper;
import com.baizhi.service.IBzLogService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xhc
 * @since 2020-09-25
 */
@Service
public class BzLogServiceImpl extends ServiceImpl<BzLogMapper, BzLog> implements IBzLogService {


    @Resource
    private BzLogMapper  bzLogMapper;

    @Override
    public Page<BzLog> selectAll(String username,Integer page, Integer size) {

        Page<BzLog> bzLogPage= new Page<>(page,size);

        QueryWrapper<BzLog> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("username",username);
        Page<BzLog> logPage =null;
        if (username!=null){
            logPage = bzLogMapper.selectPage(bzLogPage, queryWrapper);
        }else {
            logPage = bzLogMapper.selectPage(bzLogPage, null);
        }
        return logPage;
    }
}
